package com.packet.cheng.controller;

import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 @author zaicheng
 @version 1.0
 @date 2022-04-19
 @email zzc15847256473@163.com
 */

@RestController
public class SentinelAndClusterController {

    @Resource
    private RedisTemplate redisTemplate;

    @RequestMapping("/test_sentinel")
    public  void  testSentinel() throws InterruptedException {
        int i = 1;
        while (true){
            try {
                redisTemplate.opsForValue().set("zaichenghahaha"+i,i+"");
                System.out.println("设置key："+"zaichenghahaha"+i);
                i++;
                Thread.sleep(1000);
            }catch (Exception e){
                e.printStackTrace();
            }
        }
    }




}
